#ifndef _VIDEO_MEMORY_H
#define _VIDEO_MEMORY_H

#include "type.h"
#include "nes_config.h"

class CNes;
class CVideoMemory
{
  friend CNes;
public:
  CVideoMemory(CNes* nes);
  ~CVideoMemory();

  void      Reset();
  void      ClearScreen();

public:
  void      BuildTiles();
  void      BuildPatternTbl();
  void      BuildNameTbl();
  void      BuildFrame();     // Only for test
  void      BuildSprites();
  // h-syc
  void      DrawScanLine(int scanline);
  void      DrawBG(int scanline);
  void      DrawSprite(int scanline);

private:
  // 2 pattern table
  PPUTile   m_BGPattern[TILES_COUNT_IN_PTN_TBL];
  u16*      m_PatternImage;
  u16*      m_NameTblImage;
  u16*      m_SpriteImage;
  u16*      m_FrameBuf;
  u16*      m_FinalFrameBuf;
  CNes*     m_Nes;
};

#endif  // _VIDEO_MEMORY_H
